import request from "@/utils/request.ts";
import type {PermissionResponseData,MenuParams} from './type.ts'
enum API {
    ALL_PERMISSION_URL='/admin/acl/permission',//获取全部菜单与按钮的标识数据
    ADDMENU_URL='/admin/acl/permission/save',//给某一级菜单新增一个子菜单
    UPDATE_URL='/admin/acl/permission/update',//更新某一个已有的菜单
    DELETE_MENU_URL='/admin/acl/permission/remove/',//删除已有菜单
}
/**
 * 获取全部菜单与按钮的标识数据
 */
export const reqAllPermission = () => {
  return request.get<any,PermissionResponseData>(API.ALL_PERMISSION_URL)
}
/**
 * 添加或修改
 * @param data
 */
export const reqAddOrUpdateMenu = (data:MenuParams) => {
  if(data.id){
      return request.put<any>(API.UPDATE_URL,data)
  }else {
      return request.post<any>(API.ADDMENU_URL,data)
  }
}
/**
 * 删除菜单
 * @param id
 */
export const reqRemoveMenu = (id:number) => {
    return request.delete<any,any>(API.DELETE_MENU_URL+id)
}